package com.atcjx.service;

import com.atcjx.mapper.ArticleMapper;
import com.atcjx.mapper.CategoryMapper;
import com.atcjx.pojo.Article.Article;
import com.atcjx.pojo.Article.ArticleVO;
import com.atcjx.pojo.Category.CategoryVo;
import com.atcjx.pojo.Category.Theme;
import com.atcjx.pojo.Category.backInform;
import com.atcjx.pojo.Query.Article.ArticleQueryPo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author admin
 * @version 1.0.0
 * @ClassName CategoryServiceImpl.java
 * @Description TODO
 * @createTime 2021年09月21日 18:35:00
 */
@Service
public class CategoryServiceImpl  {
    @Autowired
    private CategoryMapper categoryMapper;

    public backInform getAllCategories() {
       List<CategoryVo>list= categoryMapper.selectAllCategories();
        List<Theme> themes = categoryMapper.selectAllTheme();

        return new backInform(list, themes);
    }

    public String createCategory(String category,String theme) {
        categoryMapper.deleteCategoryTheme(category);
        categoryMapper.createCategory(category,theme);
        return "创建 "+theme+" 下的："+category+" 成功！";
    }

    public String deleteCategory(String category) {
        categoryMapper.deleteCategory(category);
        return "ok";
    }

    public String deleteTheme(String theme) {
        categoryMapper.deleteTheme(theme);
        categoryMapper.originateTheme(theme);
        return "ok";
    }

    public String createCategoryOnly(String categoryName) {
        categoryMapper.creatCategoryOnly(categoryName);
        return "ok";
    }

    public String updateTheme(String oCategory,String nCategory) {
        categoryMapper.updateTheme(oCategory,nCategory);
        return "ok";
    }

    public String updateThemeByON(String newTheme, String oldTheme) {
        categoryMapper.updateCategory(newTheme,oldTheme);
        return "ok";
    }
    public String updateThemeCategory(String theme,String category){
        categoryMapper.updateCategoryTheme(theme, category);
        return "123";
    }
}
